<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MRSL JPS3D Library: include/jps_basis/data_utils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MRSL JPS3D Library
   &#160;<span id="projectnumber">1.1</span>
   </div>
   <div id="projectbrief">An implementaion of Jump Point Search on 3D voxel map</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_f3f15cb6a903102cfaa3bed9fef4749a.html">jps_basis</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">data_utils.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="data__utils_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#ifndef JPS_DATA_UTIL_H</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#define JPS_DATA_UTIL_H</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="data__type_8h.html">jps_basis/data_type.h</a>&gt;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">class</span> T, <span class="keyword">class</span> TF&gt;</div><div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="data__utils_8h.html#ac3745ddcc3002193bbcd5caab64cd1df">   12</a></span>&#160;<a class="code" href="data__type_8h.html#a6b9210d48a0a541940af71827aad1b41">vec_E&lt;T&gt;</a> <a class="code" href="data__utils_8h.html#ac3745ddcc3002193bbcd5caab64cd1df">transform_vec</a>(<span class="keyword">const</span> <a class="code" href="data__type_8h.html#a6b9210d48a0a541940af71827aad1b41">vec_E&lt;T&gt;</a> &amp;t, <span class="keyword">const</span> TF &amp;tf) {</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;  <a class="code" href="data__type_8h.html#a6b9210d48a0a541940af71827aad1b41">vec_E&lt;T&gt;</a> new_t;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;  <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> &amp;it : t)</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    new_t.push_back(tf * it);</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;  <span class="keywordflow">return</span> new_t;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;}</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;</div><div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="data__utils_8h.html#a3f82ae87bcf143405fd986be6ca44a68">   21</a></span>&#160;<a class="code" href="data__type_8h.html#a7c99d9360fc6cac2762b786e2fb52266">decimal_t</a> <a class="code" href="data__utils_8h.html#a3f82ae87bcf143405fd986be6ca44a68">total_distance</a>(<span class="keyword">const</span> <a class="code" href="data__type_8h.html#a6b9210d48a0a541940af71827aad1b41">vec_E&lt;T&gt;</a>&amp; vs){</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;  <a class="code" href="data__type_8h.html#a7c99d9360fc6cac2762b786e2fb52266">decimal_t</a> dist = 0;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;  <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 1; i &lt; vs.size(); i++)</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    dist += (vs[i] - vs[i-1]).norm();</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;  <span class="keywordflow">return</span> dist;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;}</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="data__utils_8h.html#a79960a9e7c7bad6ec5641ed1729ad8d0">   30</a></span>&#160;<span class="preprocessor">#define transform_vec3 transform_vec&lt;Vec3f, Aff3f&gt;</span></div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#define total_distance2f total_distance&lt;Vec2f&gt;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#define total_distance3f total_distance&lt;Vec3f&gt;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#define total_distance2i total_distance&lt;Vec2i&gt;</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#define total_distance3i total_distance&lt;Vec3i&gt;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="data__utils_8h_html_ac3745ddcc3002193bbcd5caab64cd1df"><div class="ttname"><a href="data__utils_8h.html#ac3745ddcc3002193bbcd5caab64cd1df">transform_vec</a></div><div class="ttdeci">vec_E&lt; T &gt; transform_vec(const vec_E&lt; T &gt; &amp;t, const TF &amp;tf)</div><div class="ttdoc">Template for transforming a vector. </div><div class="ttdef"><b>Definition:</b> data_utils.h:12</div></div>
<div class="ttc" id="data__utils_8h_html_a3f82ae87bcf143405fd986be6ca44a68"><div class="ttname"><a href="data__utils_8h.html#a3f82ae87bcf143405fd986be6ca44a68">total_distance</a></div><div class="ttdeci">decimal_t total_distance(const vec_E&lt; T &gt; &amp;vs)</div><div class="ttdoc">Template for calculating distance. </div><div class="ttdef"><b>Definition:</b> data_utils.h:21</div></div>
<div class="ttc" id="data__type_8h_html_a6b9210d48a0a541940af71827aad1b41"><div class="ttname"><a href="data__type_8h.html#a6b9210d48a0a541940af71827aad1b41">vec_E</a></div><div class="ttdeci">std::vector&lt; T, Eigen::aligned_allocator&lt; T &gt; &gt; vec_E</div><div class="ttdoc">Pre-allocated std::vector for Eigen using vec_E. </div><div class="ttdef"><b>Definition:</b> data_type.h:52</div></div>
<div class="ttc" id="data__type_8h_html_a7c99d9360fc6cac2762b786e2fb52266"><div class="ttname"><a href="data__type_8h.html#a7c99d9360fc6cac2762b786e2fb52266">decimal_t</a></div><div class="ttdeci">double decimal_t</div><div class="ttdoc">Rename the float type used in lib. </div><div class="ttdef"><b>Definition:</b> data_type.h:48</div></div>
<div class="ttc" id="data__type_8h_html"><div class="ttname"><a href="data__type_8h.html">data_type.h</a></div><div class="ttdoc">Defines all data types used in this lib. </div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
